{layout name="layout2" /}
<style>
    .img-content{
        height:80px;
        line-height:80px
    }
    .img-container {
        float: left;
        opacity: 1;
        position: relative;
    }

    .img-src {
        width: 80px;
        height: 80px;
        padding: 4px;
    }
    .img-del-x {
        position: absolute;
        z-index: 100;
        top: -4px;
        right: -2px;
        width: 20px;
        height: 20px;
        font-size: 16px;
        line-height: 16px;
        color: #fff;
        text-align: center;
        cursor: pointer;
        background: hsla(0, 0%, 60%, .6);
        border-radius: 10px;
    }
    .layui-form-item .layui-input-inline{
        margin-top:10px;
    }
    .layui-form-label {
        color: #6a6f6c;
        width: 100px;
        line-height: 15px;
    }
    #container {
        margin-left: 130px;
        width: 60%;
        height: 60%;
    }
    .tips{
        color: red;
    }
    .goods-li {
        float: left;
        opacity: 1;
        position: relative;
    }

    .goods-img {
        width: 80px;
        height: 80px;
        padding: 4px;
    }
    .goods-img-del-x {
        position: absolute;
        z-index: 100;
        top: -4px;
        right: -2px;
        width: 20px;
        height: 20px;
        font-size: 16px;
        line-height: 16px;
        color: #fff;
        text-align: center;
        cursor: pointer;
        background: hsla(0, 0%, 60%, .6);
        border-radius: 10px;
    }
    .layui-input-block {
        margin-left: 130px;
    }
    #image{
        left:110px;
    }
</style>
<script charset="utf-8" src="https://map.qq.com/api/gljs?v=1.exp&libraries=service&key=E2WBZ-XPM3B-VTOUQ-NZQTD-KHBHT-ZYBVF"></script>
<div class="layui-form" lay-filter="layuiadmin-form-user" id="layuiadmin-form-user" style="padding: 20px 30px 0 0;">
   <input type="hidden" name="id" value="{$info.id}">

    <div class="layui-form-item">
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="tips">*</span>姓名：</label>
            <div class="layui-input-block">
                <input type="text" name="dname" value="{$info.dname}" lay-verify="required" lay-verType="tips" placeholder="请输入姓名" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="tips">*</span>手机账号</label>
            <div class="layui-input-block">
                <input type="text" name="dmobile" value="{$info.dmobile}" lay-verify="required" lay-verType="tips" placeholder="请输入手机账号" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="tips">*</span>用户类型：</label>
            <div class="layui-input-block">
                <select name="dtype" class="layui-input">
                    <option value="">请选择用户类型</option>
                    <option value="1" {if condition="$info.dtype == '配送员'"}selected{/if}>配送员</option>
                    <option value="2" {if condition="$info.dtype == '司机'"}selected{/if}>司机</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">所属站点:</label>
            <div class="layui-input-block">
                <select name="site_id" id="site_id" class="layui-input">
                    <option value="">请选择站点</option>
                    {foreach $bottle_site_list as $val}
                    <option value="{$val.id}" {if condition="$val.name == $info.site_id"}selected{/if}>{$val.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">账号状态：</label>
            <div class="layui-input-block">
                <input type="radio" name="dstatus" value="1" title="正常" {if $info.dstatus == '正常'}checked{/if}>
                <input type="radio" name="dstatus" value="2" title="禁用" {if $info.dstatus == '禁用'}checked{/if}>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">配送员头像</label>
            <div class="layui-input-inline">
                <div style="height:80px;line-height:80px">
                    <input name="davatar" type="hidden" value="{$info.davatar}">
                    {if !empty($info.davatar)}
                    <div class="goods-img-add" style="display: none" ></div>
                    <div class="goods-li">
                        <img class="goods-img" src="{$info.davatar}">
                        <a class="goods-img-del-x" style="display: none">x</a>
                    </div>
                    {else}
                    <div class="goods-img-add" ></div>
                    {/if}
                </div>
            </div>
            <div class="layui-input-inline">
                <label class=" layui-form-mid layui-word-aux" id="image">建议尺寸：200*200像素</label>
            </div>
        </div>
    </div>

    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="edit-submit"  id="edit-submit" value="确认">
    </div>
</div>
<script>
    layui.config({
        version:"{$front_version}",
        base: '/static/plug/layui-admin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form','laydate','like'], function(){
        var $ = layui.$
            ,form = layui.form
            ,laydate = layui.laydate
            ,like = layui.like;
        laydate.render({
            elem: '#reg_time'
            // ,format: 'yyyy-MM-dd H:i'
            ,type: 'datetime'
            ,trigger: 'click'
        });
        laydate.render({
            elem: '#order_last_time'
            // ,format: 'yyyy-MM-dd H:i'
            ,type: 'datetime'
            ,trigger: 'click'
        });
        laydate.render({
            elem: '#create_time'
            // ,format: 'yyyy-MM-dd H:i'
            ,type: 'datetime'
            ,trigger: 'click'
        });
        //上传图片
        like.imageUpload('.goods-img-add', function (uri, element) {
            if(uri.length>1){
                layer.msg('最多最能选中1张图片');
                return;
            }
            var html = '<div class="goods-li">\n' +
                '<img class="goods-img" ' +
                'src="' + uri[0] + '">' +
                '<a class="goods-img-del-x">x</a>' +
                '</div>';
            element.prev().val(like.getUrlFileName(uri[0], '{$storageUrl}'));
            element.parent().append(html);
            element.css('display','none');
        }, true);
        //删除图片
        $(document).on('click', '.goods-img-del-x', function () {
            $(this).parent().siblings('input').val('');
            $(this).parent().prev().css('display','block');
            $(this).parent().remove();
        });
        //显示图片
        $(document).on('click', '.goods-img', function () {
            var image = $(this).attr('src');
            like.showImg(image,600);
        });

        //  删除按钮的显示与隐藏
        $(document).on('mouseover', '.goods-img', function () {
            $(this).next().show();
        });
        $(document).on('mouseout', '.goods-img', function () {
            $(this).next().hide();
        });
        $(document).on('mouseover', '.goods-img-del-x', function () {
            $(this).show();
        });
        $(document).on('mouseout', '.goods-img-del-x', function () {
            $(this).hide();
        });

        form.on('select(category)', function(data){
            var level = $(data.elem).find("option:selected").attr("data-level");
            $('.alliance_ratio').hide();
            $('.autotrophy_ratio').hide();
            if(level == 2){
                $('.alliance_ratio').show();
                $('.autotrophy_ratio').show();

            }
        });

    })
    var map = new TMap.Map('container', {
  zoom: 14,
  center: new TMap.LatLng(28.24826,113.1155 ),
});
var geocoder = new TMap.service.Geocoder(); // 新建一个正逆地址解析类
var markers = new TMap.MultiMarker({
  map: map,
  geometries: [],
});


function convert() {
    console.log("获取地址",document.getElementById('address').value)
  markers.setGeometries([]);
  // 将给定的地址转换为坐标位置
  geocoder
    .getLocation({ address: document.getElementById('address').value })
    .then((result) => {
      markers.updateGeometries([
        {
          id: 'main',
          position: result.result.location, // 将得到的坐标位置用点标记标注在地图上
        },
      ]);
      map.setCenter(result.result.location);
      // document.getElementById(
      //   'longitude'
      // ).value = result.result.location;
      //result.result.location.lng.lat;
      document.getElementById(
        'latitude'
      ).value = result.result.location;
      
      // 显示坐标数值
    });
}
convert();
</script>